﻿using System;
using System.Collections.Generic;
using WareDealer.Mode;

namespace WareDealer.Works
{
    public class ProcessItem : IWorkProcessItem
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 优先级
        /// </summary>
        public int Priority { get; set; }
        /// <summary>
        /// 工作内容
        /// </summary>
        public Object WorkItems { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public EnumGatherStatu Statu { get; internal set; }
        /// <summary>
        /// 返回结果集
        /// </summary>
        public object ResultItems { get; internal set; }

        /// <summary>
        /// 时长
        /// </summary>
        public int Time { get; set; }

        public virtual void ExecItem() {}

        public List<string> ProcessBarIDs { get; set; }
        public Action<string, int> InitProcess { get; set; }

        public Action<string, int> ShowStep { get; set; }

        public Action<string> ShowMessage { get; set; }

        public Action<string, bool> EndProcess { get; set; }

        #region Release Private Method

        protected void InitAutoProcess(string processid, int iLength)
        {
            if (!string.IsNullOrEmpty(processid) && InitProcess != null)
            {
                InitProcess(processid, iLength);
            }
        }

        protected void ShowAutoStep(string processid, int iStep)
        {
            if (!string.IsNullOrEmpty(processid) && ShowStep != null)
            {
                ShowStep(processid, iStep);
            }
        }

        protected void EndAutoProcess(string processid, bool bRtn)
        {
            if (!string.IsNullOrEmpty(processid) && EndProcess != null)
            {
                EndProcess(processid, bRtn);
            }
        }

        protected void ShowAutoMessage(string msg)
        {
            if (ShowMessage != null)
            {
                ShowMessage(msg);
            }
        }

        #endregion Release Private Method

    }
}
